﻿using IdentityService.Domain.Services;
using MediatR;

namespace IdentityService.Application.Commands
{
    public record UserSignUpCommand(string UserName, string Password) : IRequest<SignUpResult>;

    public class UserSignUpCommandHandler : IRequestHandler<UserSignUpCommand, SignUpResult>
    {
        private readonly IUserAccountService _service;
        public UserSignUpCommandHandler(IUserAccountService service) => _service = service;

        public async Task<SignUpResult> Handle(UserSignUpCommand request, CancellationToken cancellationToken)
        {
            return await _service.SignUpAsync(request.UserName, request.Password);
        }
    }
}
